{% extends "base.html" %}

{% block content %}
<div class="container-fluid">
	<div class="row clearfix">

	<form id="form-submitsql" action="/autoreview/" method="post" class="form-horizontal" role="form">
		{% csrf_token %}
        <input type="hidden" id="workflowid" name="workflowid"/>
		<div class="col-md-8 column">
			<textarea id="sql_content" name="sql_content" class="form-control" data-name="SQL内容" placeholder="请在此提交SQL，请以分号结尾。例如：use test; create table t1(id int)engine=innodb;" rows=20 required></textarea>
		</div>

		<div class="col-md-4 column">
				<div class="form-group">
					<input id="workflow_name" type="text" name="workflow_name" class="form-control" data-name="上线单名称" placeholder="请输入上线单名称，如:XX项目会员功能建表" required>
				</div>
				<div class="form-group">
					<select id="cluster_name" name="cluster_name" class="selectpicker show-tick form-control bs-select-hidden" data-name="要上线的集群" data-placeholder="请选择要上线的集群:" required>
          				<option value="is-empty" disabled="" selected="selected">请选择要上线的集群:</option>
						{% for cluster_name,dbs in dictAllClusterDb.items %}
							<option value="{{cluster_name}}">{{cluster_name}}集群 (包含db：
							{% for db in dbs %}
								{{db}}{% if not forloop.last %},{% endif%}
							{% endfor %}
							)
							</option>
                        {% endfor %}
						        		
					</select>					
				</div>
				<div class="form-group">
					<select id="is_backup" name="is_backup" class="selectpicker show-tick form-control bs-select-hidden" data-name="是否选择备份" data-placeholder="请选择是否要备份:" required>
          				<option value="is-empty" disabled="" selected="selected">请选择是否要备份:</option>
          				<option value="是">是</option>
          				<option value="否">否</option>
        			</select>	
				</div>
				<div class="form-group">
					<select id="review_man" name="review_man" class="selectpicker show-tick form-control bs-select-hidden" data-name="审核人" data-placeholder="请选择RD审核人:" required>
          			<option value="is-empty" disabled="" selected="selected">请选择审核人:</option>
					{% for man in reviewMen %}
					<option value="{{man}}">{{man}}</option>
					{% endfor %}
					</select>
				</div>
                <!--增加副审核人选项-->
                <div class="form-group">
                    <div class="panel-group" id="accordion">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h4 class="panel-title">
                                    <a data-toggle="collapse"
                                    data-parent="#accordion"
                                       href="#collapseOne">
                                        <i class="glyphicon-plus
                                        glyphicon"></i>
                                        增加副审核人（可选)
                                    </a>
                                </h4>
                            </div>
                            <div id="collapseOne" class="panel-collapse
                            collapse">
                                <div class="panel-body" style="margin-left:
                                25px">
                                    {% for man in reviewMen %}
                                        <div class="radio" id="{{ man }}">
                                            <input type="radio" id="radio1"
                                            name="sub_review_man" value="{{ man }}" />
                                            <label for="radio1"> {{ man }}
                                            </label>
                                        </div>
                                    {% endfor %}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
				<div class="form-group">
                    <input type="button" id="btn-autoreview" class="btn btn-info btn-lg" value="SQL检测" />
                    <button type="reset" class="btn btn-warning">清空选项</button>
                    <!-- <button type="submit" class="btn btn-primary">SQL提交</button> -->
                    <input id="btn-submitsql" type="button" class="btn btn-primary" value="SQL提交" />
				</div>
	</form>
		</div>
	</div>

	<div id="inception-result" style="display:none;" class="row clearfix">
		<br/>
		<div id="inception-result-col" class="col-md-12">
		
		</div>
	</div>
</div>
</div>
<script type="text/javascript">
    var pathname = window.location.pathname;
    if (pathname == "/editsql/") {
        document.getElementById('workflowid').value = sessionStorage.getItem('editWorkflowDetailId');
        document.getElementById('workflow_name').value = sessionStorage.getItem('editWorkflowNname');
        document.getElementById('sql_content').value = sessionStorage.getItem('editSqlContent');
    }
</script>
{% endblock content %}
